<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    <div class="box">
        <div class="msg"></div>
        <div class="input">
            <textarea id="txt"></textarea>
            <input type="button" value="发送" id="send">
        </div>
    </div>
</body>
<script>
    var omsg = document.querySelector(".msg");
    var otxt = document.getElementById("txt");
    var osend = document.getElementById("send");

    osend.onclick = function(){

        // 创建元素
        var p = document.createElement("p");
        // 添加内容
        p.innerHTML = otxt.value;
        // 插入到消息区
        omsg.appendChild(p);

        otxt.value = "";

    }

</script>
</html>